<template>
  <page-header-wrapper>
    <page-tab-list>
      <div class="table-page-search-box">
        <a-form layout="inline">
          <a-row :gutter="24">
            <a-col :md="8" :sm="24">
              <a-form-item label="订单号">
                <a-input placeholder="请输入订单号" v-model="queryParam.order_no"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="发放时间">
                <div class="select">
                  <a-range-picker
                    format="YYYY-MM-DD HH:mm"
                    valueFormat="YYYY-MM-DD HH:mm"
                    :placeholder="['开始时间', '结束时间']"
                    v-model="queryTime"
                    @change="changeTime"
                  />
                  <a-button type="primary" @click="getList">查询</a-button>
                </div>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </page-tab-list>
    <a-card :bordered="false">
      <div class="table-operator" style="display: flex; justify-content: space-between">
        <a-radio-group v-model="queryParam.is_send" @change="getList">
          <a-radio-button value="-1"> 全部 </a-radio-button>
          <a-radio-button value="1"> 已发放 </a-radio-button>
          <a-radio-button value="0"> 未发放 </a-radio-button>
        </a-radio-group>
      </div>

      <a-table
        :rowKey="
          (r, i) => {
            return i
          }
        "
        :pagination="{
          total: this.totalCount,
          showSizeChanger: false,
          onChange: this.tablePageChange,
        }"
        :columns="columns"
        :data-source="list"
        :scroll="{ x: 'max-content' }"
      >
        <div slot="name" slot-scope="text, record">
          <div class="name">
            <div class="pic">
              <img :src="record.holder_avatar" alt="" />
            </div>
            <div class="info">
              <a-tooltip>
                <template slot="title">
                  {{ record.holder_name }}
                </template>
                <span>{{ record.holder_name }}</span>
              </a-tooltip>
            </div>
          </div>
        </div>

        <span slot="is_send" slot-scope="text">
          {{ text === '1' ? '已发放' : '未发放' }}
        </span>
      </a-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { shareFrostLogList } from '@/api/shareholder'
const columns = [
  {
    title: '用户信息',
    scopedSlots: {
      customRender: 'name',
    },
  },
  {
    title: '订单号',
    dataIndex: 'order_no',
  },
  {
    title: '金额(元)',
    dataIndex: 'money',
  },
  {
    title: '状态',
    dataIndex: 'is_send',
    scopedSlots: {
      customRender: 'is_send',
    },
  },
  {
    title: '创建时间',
    dataIndex: 'created_at',
  },
  {
    title: '发放时间',
    dataIndex: 'send_time',
  },
]
export default {
  data() {
    return {
      // 搜索参数
      queryParam: {
        order_no: null,
        is_send: '-1',
        send_start_time: null,
        send_end_time: null,
        pageNo: 1,
        pageSize: 10,
        type: 1,
      },
      list: [],
      columns,
      totalCount: 0,
      queryTime: [],
    }
  },

  methods: {
    async getList() {
      const hide = this.$message.loading('加载中', 0)
      const res = await shareFrostLogList(this.queryParam)
      if (res.code == 0) {
        this.totalCount = res.data.totalCount
        this.list = res.data.data
      }
      hide()
    },

    tablePageChange(e) {
      this.queryParam.pageNo = e
      this.getList()
    },

    changeTime(e) {
      if (e.length) {
        this.queryParam.send_start_time = e[0]
        this.queryParam.send_end_time = e[1]
      } else {
        this.queryParam.send_start_time = null
        this.queryParam.send_end_time = null
      }
    },
  },
  mounted() {
    this.getList()
  },
}
</script>

<style lang="less" scoped>
.search {
  /deep/ .ant-card-body {
    padding-top: 0 !important;
    padding-bottom: 14px !important;
  }
}
.searchBox {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /deep/ .ant-input-affix-wrapper {
    width: 220px;
    margin-top: 14px;
    margin-right: 20px;
  }
  .select {
    display: flex;
    align-items: center;
    margin-top: 14px;
    margin-right: 20px;
  }
  .ant-btn {
    margin-top: 14px;
  }
}
.name {
  display: flex;
  align-items: center;
  width: 200px;

  .pic {
    width: 48px;
    min-width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 24px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .info {
    flex: auto;
    width: 0;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    span {
      width: 100%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    span:nth-child(2) {
      color: rgba(0, 0, 0, 0.45);
      margin-top: 6px;
    }
  }
}
.action {
  display: flex;
  align-items: center;
  .line {
    width: 1px;
    height: 14px;
    background-color: #d8d8d8;
  }
}
.level_one_count {
  text-decoration: underline;
  cursor: pointer;
  color: #ff4400;
}
</style>
